#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

ll a, b, mod;
ll mul(ll a, ll b, ll mod) {
  ll res = 0;
  while (b) {
    if (b & 1) res = (res + a) % mod;
    a = a * 2 % mod;
    b >>= 1;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> a >> b >> mod;
  cout << mul(a, b, mod);
  return 0;
}